using System;
using System.IO;

namespace VCDepend.Engine.Graphviz
{
	public class DotEdge : IDotSerializable
	{
		public readonly string From;
		public readonly string To;

		private DotAttributes m_attributes;

		public DotEdge(string from, string to)
		{
			From = from;
			To = to;

			m_attributes = new DotAttributes(" [", ",", "]");
		}

		public void SetAttribute(string name, string value)
		{
			m_attributes.SetAttribute(name, value);
		}

		public void Serialize(TextWriter writer)
		{
			writer.Write("{0} -> {1}", DotUtil.EscapeDotString(From), DotUtil.EscapeDotString(To));
			m_attributes.Serialize(writer);
			writer.Write(";");
		}
	}
}
